package com.xiaoran.robot.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 返回的消息构成
 */
public class RstMsgUtils {
    private final ArrayList<Object> rstMsgChain = new ArrayList<>();
    public RstMsgUtils(){

    }

    public RstMsgUtils addText(String text){
        HashMap<String, Object> node = new HashMap<>();
        node.put("type", "Plain");
        node.put("text", text);
        rstMsgChain.add(node);
        return this;
    }

    /**
     * 本地图片
     * @param path 本地图片路径，例如：D:/img
     */
    public RstMsgUtils addImagePath(String path){
        HashMap<String, Object> node = new HashMap<>();
        node.put("type", "Image");
        node.put("path", path);
        rstMsgChain.add(node);
        return this;
    }
    /**
     * 网络图片
     * @param url 网络图片路径，例如：http://xiaoran.top/test.img
     */
    public RstMsgUtils addImageUrl(String url){
        HashMap<String, Object> node = new HashMap<>();
        node.put("type", "Image");
        node.put("url", url);
        rstMsgChain.add(node);
        return this;
    }

    public RstMsgUtils atQQ(String qq){
        HashMap<String, Object> node = new HashMap<>();
        node.put("type", "At");
        node.put("target", qq);
        node.put("display", "xiaoran");
        rstMsgChain.add(node);
        return this;
    }
    public RstMsgUtils atAll(){
        HashMap<String, Object> node = new HashMap<>();
        node.put("type", "AtAll");
        rstMsgChain.add(node);
        return this;
    }

    public ArrayList<Object> build(){
        return this.rstMsgChain;
    }



}
